<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <%@include file="../../common.jsp"%>
    <title>查询消缺任务</title>
    <style>
        .top{
            border: 1px solid #999999;
        }
        .top{
            border: 1px solid #999999;
            margin-top: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<h2>查看消缺任务</h2>
<hr>
<div class="top">
    <form class="layui-form" lay-filter="taskForm" id="taskForm" action="" style="padding:15px 10px;">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">任务编号:</label>
            <div class="layui-input-inline">
                <input type="text" name="solveTaskCode" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">任务名称:</label>
            <div class="layui-input-inline">
                <input type="text" name="solveTaskName" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">任务状态:</label>
            <div class="layui-input-inline">
                <input type="text" name="taskStateName" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作单据:</label>
            <div class="layui-input-inline">
                <input type="text" name="workDocTypeName" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">任务下发人:</label>
            <div class="layui-input-inline">
                <input type="text" name="issuedByName" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">任务下发时间:</label>
            <div class="layui-input-inline">
                <input type="text" name="issuedTime" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">任务负责人:</label>
            <div class="layui-input-inline">
                <input type="text" name="taskManagerName" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">任务描述:</label>
            <div class="layui-input-inline">
                <input type="text" name="taskDesc" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">消缺员:</label>
            <div class="layui-input-inline">
                <input type="text" name="solvers" required readonly  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">任务完成时间:</label>
            <div class="layui-input-inline">
                <input type="text" name="finishTime" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">负责人审查意见:</label>
            <div class="layui-input-inline">
                <input type="text" name="managerSuggestion" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">完成情况描述:</label>
            <div class="layui-input-inline">
                <input type="text" name="taskFinishDesc" required readonly lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下发人审查意见:</label>
            <div class="layui-input-inline">
                <input type="text" name="issuedSuggestion" required   lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">是否通过:</label>
            <div class="layui-input-inline">
                <select id="state" lay-filter="state">
                    <option value="-1">请选择</option>
                    <option value="0">通过</option>
                    <option value="1">未通过</option>
                </select>
            </div>
        </div>
        <h3>缺陷信息列表</h3>
        <table class="layui-table" id="bugTable" lay-filter="bugTable"></table>

        <div class="layui-form-item">
            <label class="layui-form-label">工作间断延期记载:</label>
            <div class="layui-input-inline">
                <textarea name="taskNotes" cols="60" rows="5" readonly></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作终结报告:</label>
            <div class="layui-input-inline">
                <textarea name="taskFinishReport" cols="60" rows="5" readonly></textarea>
            </div>
        </div>
    </form>
</div>
<div>
    <button type="button" class="layui-btn layui-btn-normal" onclick="save()">保存</button>
    <button type="button" class="layui-btn layui-btn-normal" onclick="fanhui()">返回</button>
</div>
    <script>
        var state = -1;
        function fanhui(){
            history.go(-1);
        }
        layui.use(['laydate','table','form'],function () {
            //渲染表格
            var table = layui.table;
            table.render({
                id:'bugTable',
                elem:'#bugTable',
                url:'/solveTaskMain/getSolveTask',
                even:false,
                cols:[[
                    {field:'lineCode', title:'线路编号'},
                    {field:'poleCode', title:'杆塔编号'},
                    {field:'bugLevelName', title:'缺陷级别'},
                    {field:'bugTypeName', title:'缺陷类型'},
                    {field:'bugDesc', title:'缺陷描述'},
                    {field:'discovererName', title:'发现人'},
                    {field:'discoverTime', title:'发现时间'},
                ]]
            })

            //获取消缺任务信息
            $.get("/solveTaskMain/getTask",{"taskId":${sessionScope.solveTaskId},},function (data) {
                layui.form.val("taskForm",data);
            })
            layui.form.on('select(state)', function(data){
                state = data.value;
            })
        });


        //保存
        function save() {
            //保存回执信息
            //获取表单数据
            if(state == -1){
                alert("请审查缺陷");
            }else{
                //审查缺陷是否通过
                $.get("/solveReturn/shencha",{state:state},function (data) {
                    if(data){
                        layer.msg('保存成功!',{icon:1})
                    }
                })
            }
        }

        //上传回执
        function upload() {
            //获取表单信息
            var taskFinishDesc = $(":input[name = 'taskFinishDesc']").val();
            var taskNotes = $(":input[name = 'taskNotes']").val();
            var taskFinishReport = $(":input[name = 'taskFinishReport']").val();
            //修改缺陷信息
            $.get("/solveReturn/upload",{"taskFinishDesc":taskFinishDesc,"taskNotes":taskNotes,"taskFinishReport":taskFinishReport},function (data) {
                if(data){
                    layer.msg('上传回执成功!',{icon:1})
                    var t=setTimeout(fanhui(),1000);
                }
            })
        }
    </script>
</div>
</body>
</html>